import {createStore, applyMiddleware} from 'redux'
import thunk from 'redux-thunk'
import { routerMiddleware } from 'react-router-redux'
import {createHashHistory} from 'history'

const history = createHashHistory()
//创建初始化tab
history.replace('home')
// 创建history的middleware
const historyMiddle = routerMiddleware(history)

import reducers from './reducers/main.js'

const store = createStore(reducers, applyMiddleware(thunk, historyMiddle))

if(module.hot){
  module.hot.accept('./reducers/main.js', () => {
    const nextRootReducers = require('./reducers/main.js').default
    store.replacereducer(nextRootReducers)
  })
}
module.exports = {
  store,
  history
}